<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header">修改密码</div>
        <div class="layui-card-body" pad15="">
                <div class="layui-form" lay-filter="">
                    <div class="layui-form-item">
                        <label class="layui-form-label">当前密码</label>
                        <div class="layui-input-inline">
                            <input type="password" name="oldPassword" lay-verify="required" lay-vertype="tips" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">新密码</label>
                        <div class="layui-input-inline">
                            <input type="password" name="password" lay-verify="pass" lay-vertype="tips" autocomplete="off" id="LAY_password" class="layui-input">
                        </div>
                        <div class="layui-form-mid layui-word-aux">6到16个字符</div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">确认新密码</label>
                        <div class="layui-input-inline">
                            <input type="password" name="repassword" lay-verify="repass" lay-vertype="tips" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn" onclick="submit()">确认修改</button>
                        </div>
                    </div>
                </div>
        </div>
    </div>
</div>
<script>
    function submit(){
        layui.use(['form'], function() {
            var oldpwd = $("input[name=oldPassword]").val();
            var pwd = $("input[name=password]").val();
            var repassword = $("input[name=repassword]").val();
            if(oldpwd == "" || pwd == "" || repassword == "") {
                layer.msg("密码不能为空");
                return;
            }
            if(pwd != repassword){
                layer.msg("两次密码不一样");
            }else {
                $.post("/ajax/fore/updateuserpassword",{oldPwd:oldpwd,newPwd:pwd},function(result){
                    layer.msg(result.result);
                });
            }
        });
    }

</script>